import React from 'react';
import {
  SafeAreaView,
  ScrollView,
  StatusBar,
  StyleSheet,
  Text,
  useColorScheme,
  View,
  Button,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import {StackNavigationProp} from '@react-navigation/stack';
export default () => {
  const navigation = useNavigation<StackNavigationProp<any>>();
  const onButtonPress = () => {
    console.log('打印点击');

    // navigation.push('PageB');
    // navigation.replace('PageB') 回退 要前面有才行
    // navigation.goBack() 一直返回
    // if (navigation.canGoBack()) {
    //   navigation.goBack();
    // }
    navigation.pop() //直接弹出
  };
  return (
    <View
      style={{
        width: '100%',
        height: '100%',
        backgroundColor: 'pink',
        justifyContent: 'center',
        alignItems: 'center',
      }}>
      <Text
        style={{
          fontSize: 40,
          color: '#333',
          fontWeight: 'bold',
        }}>
        页面B
      </Text>
      <Button title="点击跳转" onPress={onButtonPress}></Button>
    </View>
  );
};
